<template>
  <div id="app">
    <div class="center-loading" v-if="loading">
      <spinner type="bubbles" size="40px"></spinner>
    </div>
    <img class="no-bg" src="./assets/nomore_bg.jpg" v-if="nodata">
    <div class="tabbar">
      <div class="tab-item">
        <router-link to="/order">
          <span class="icon iconfont icon-qiangdan1"></span>
          <p class="text">抢单</p>
        </router-link>
      </div>
      <div class="tab-item">
        <router-link to="/task">
          <span class="icon iconfont icon-renwu1"></span>
          <p class="text">任务</p>
        </router-link>
      </div><div class="tab-item">
        <router-link to="/courier">
          <span class="icon iconfont icon-kuaidi"></span>
          <p class="text">快递</p>
        </router-link>
      </div>
      <div class="tab-item">
        <router-link to="/mine">
          <span class="icon iconfont icon-qishou"></span>
          <p class="text">我的</p>
        </router-link>
      </div>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
import { Spinner } from 'vux'
import {mapGetters} from 'vuex'
import { mapState } from 'vuex'
export default {
  name: 'app',
  components: {
    Spinner
  },
  computed: {
    ...mapGetters([
       'loading',
       'nodata'
    ]),
  },
 
  created(){
    if(localStorage.getItem("logined")){
      let token = localStorage.getItem("access_token");
      this.ajaxplugin("/Deliver/check_login",{"access_token":token},(res) => {
        if(res.result == 'error'){
          this.$router.push('/login');
        }
      })
    }else{
      this.$router.push('/login');
    }
    
    // let url = '/Deliver/login'
    // let params = {'name':'17602980316','password':'123456'}
    // this.ajaxplugin(url,params,(res) => {
    //     console.log(res)
    // })

  },
  
}
</script>

<style lang="stylus">
@import 'common/css/reset.css';
@import 'common/css/style.css';
@import 'common/fonts/iconfont.css';
.no-bg
  width 100%
  height 100vh
  background-size: cover
.tabbar
  z-index:9
  position:fixed
  left:0
  bottom:0
  width:100%
  height:48px
  display:flex
  background-color: rgba(242, 242, 242, 1);
  border-top:1px solid rgba(216, 216, 216, 1);
  .tab-item
    flex:1
    display:inline-block
    height:50px
    line-height:50px
    position:relative
    &:nth-child(2)
      .icon
        font-size 24px
    .router-link-active
      color:#108EE9
    .icon
      position: absolute
      top: 8px
      left: 0
      right 0
      text-align center
      font-size: 20px
      height: 20px
      line-height: 20px
    .text
      position: absolute
      top: 30px
      left: 0
      right 0
      text-align center
      font-size: 14px
      height: 14px
      line-height: 14px

</style>
